﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FontSizeWidget
{
    /// <summary>
    /// Interaction logic for FontSize.xaml
    /// </summary>
    public partial class FontSize : UserControl
    {
        private double size;

        public FontSize()
        {
            InitializeComponent();
            this.ForceCursor = true;
        }

        public double Size
        {
            get
            {
                return size;
            }
            set 
            {
                size = value;
                Dispatcher.Invoke(new Action(() => { SizeMessage.Text = string.Format("{0}px", size); }));
            }
        }

        public string Advice
        {
            get 
            {
                return Message.Text;
            }
            set 
            {
                Dispatcher.Invoke(new Action(() => { Message.Text = value; }));
            }
        }

        public event EventHandler BigAClicked;

        public event EventHandler SmallAClicked;

        private void BigAButton_Click(object sender, RoutedEventArgs e)
        {
            if (BigAClicked != null)
            {
                BigAClicked(sender, new EventArgs());
            }
            Advice = string.Empty;
        }

        private void SmallAButton_Click(object sender, RoutedEventArgs e)
        {
            if (SmallAClicked != null)
            {
                SmallAClicked(sender, new EventArgs());
            }
            Advice = string.Empty;
        }

        private void BigAButton_MouseEnter(object sender, MouseEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Hand;
        }

        private void BigAButton_MouseLeave(object sender, MouseEventArgs e)
        {
            Mouse.OverrideCursor = null;
        }

        private void SmallAButton_MouseEnter(object sender, MouseEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Hand;
        }

        private void SmallAButton_MouseLeave(object sender, MouseEventArgs e)
        {
            Mouse.OverrideCursor = null;
        }

    }
}
